home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mgr_2 / lib / dump.h < prev    next >
C/C++ Source or Header  |  1989-01-24  |  3KB  |  113 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: dump.h,v 4.2 88/07/20 15:16:24 sau Exp $
  9.     $Source: /tmp/mgrsrc/lib/RCS/dump.h,v $
  10. */
  11. static char    h_dump_[] = "$Source: /tmp/mgrsrc/lib/RCS/dump.h,v $$Revision: 4.2 $";
  12. /* format for saved bitmaps */
  13.  
  14. #define B_HSIZE        (sizeof(struct b_header))
  15. #define B_OHSIZE        (sizeof(struct old_b_header))
  16.  
  17. #define NEW_BHDR    1    /* flag for bitmapwrite */
  18. #define OLD_BHDR    0    /* " */
  19.  
  20. /* given bitmap header, get w[idth] and h[eight] */
  21.  
  22. #define B_GETOLDHDR(hdr,W,H) ( \
  23.     W = ((int)((hdr)->h_wide - ' ') << 6) + (hdr)->l_wide - ' ', \
  24.     H = ((int)((hdr)->h_high - ' ') << 6) + (hdr)->l_high - ' ')
  25.  
  26. #define B_GETHDR8(hdr,W,H,D) ( \
  27.     W = ((int)((hdr)->h_wide - ' ') << 6) + (hdr)->l_wide - ' ', \
  28.     H = ((int)((hdr)->h_high - ' ') << 6) + (hdr)->l_high - ' ', \
  29.     D = ((int)((hdr)->depth - ' ')))
  30.  
  31. /* given w[idth] and h[eight], produce header */
  32.  
  33. #define B_PUTOLDHDR(hdr,w,h) \
  34.     (hdr)->magic[0]='z', (hdr)->magic[1]='z', \
  35.     (hdr)->h_wide = (((w)>>6)&0x3f) + ' ', \
  36.     (hdr)->l_wide = ((w)&0x3f) + ' ', \
  37.     (hdr)->h_high = (((h)>>6)&0x3f) + ' ', \
  38.     (hdr)->l_high = ((h)&0x3f) + ' '
  39. #define B8_PUTOLDHDR(hdr,w,h) \
  40.     (hdr)->magic[0]='z', (hdr)->magic[1]='y', \
  41.     (hdr)->h_wide = (((w)>>6)&0x3f) + ' ', \
  42.     (hdr)->l_wide = ((w)&0x3f) + ' ', \
  43.     (hdr)->h_high = (((h)>>6)&0x3f) + ' ', \
  44.     (hdr)->l_high = ((h)&0x3f) + ' '
  45.  
  46. #define B_PUTHDR8(hdr,w,h,d) ( \
  47.     (hdr)->magic[0]='y', (hdr)->magic[1]='z', \
  48.     (hdr)->h_wide = (((w)>>6)&0x3f) + ' ', \
  49.     (hdr)->l_wide = ((w)&0x3f) + ' ', \
  50.     (hdr)->h_high = (((h)>>6)&0x3f) + ' ', \
  51.     (hdr)->l_high = ((h)&0x3f) + ' ', \
  52.     (hdr)->depth = ((d)&0x3f) + ' ', \
  53.     (hdr)->_reserved = ' ' )
  54.  
  55.  
  56. /*    Bitmap header magic numbers for 1-bit-deep bitmaps with
  57.     8, 16, and 32 bit padding.
  58.     16 and 32 bit padding are ancient history, but still acknowledged.
  59. */
  60. #define B_ISHDR8(hdr)    ((hdr)->magic[0]=='y' && (hdr)->magic[1]=='z')
  61.  
  62. #define B_ISHDR16(hdr) \
  63.     ((hdr)->magic[0]=='z' && (hdr)->magic[1]=='z')
  64. #define B_ISHDR32(hdr) \
  65.     ((hdr)->magic[0]=='x' && (hdr)->magic[1]=='z')
  66.  
  67. #ifdef ALIGN32
  68. #define B_ISHDR(hdr)    B_ISHDR32(hdr)
  69. #define B8_ISHDR(hdr) \
  70.     ((hdr)->magic[0]=='x' && (hdr)->magic[1]=='y')
  71. #else
  72. #define B_ISHDR(hdr)    B_ISHDR16(hdr)
  73. #define B8_ISHDR(hdr) \
  74.     ((hdr)->magic[0]=='z' && (hdr)->magic[1]=='y')
  75. #endif
  76.  
  77. /*
  78.     #ifdef COLOR
  79.     #define B_ISANY(hdr) \
  80.         (B_ISHDR(hdr) || B8_ISHDR(hdr))
  81.     #else
  82.     #define B_ISANY(hdr)    B_ISHDR(hdr)
  83.     #endif
  84. */
  85.  
  86. /* number of bytes of data for bitmap */
  87.  
  88. #define B_SIZE8(w,h,d)    ((h)*((((w*d)+7L)&~7L)>>3))
  89. #define B_SIZE16(w,h,d)    ((h)*((((w*d)+15L)&~15L)>>3))
  90. #define B_SIZE32(w,h,d)    ((h)*((((w*d)+31L)&~31L)>>3))
  91. #define B_SIZE(w,h)    ((h)*((((w)+BITS)&~BITS)>>3))
  92. #define B8_SIZE(w,h)    ((h)*(w))
  93.  
  94. struct old_b_header {
  95.    char magic[2];
  96.    char h_wide;
  97.    char l_wide;
  98.    char h_high;
  99.    char l_high;
  100.    };
  101.  
  102. struct b_header {
  103.    char magic[2];
  104.    char h_wide;
  105.    char l_wide;
  106.    char h_high;
  107.    char l_high;
  108.    char depth;
  109.    char _reserved;    /* to pad b_header out to 8 bytes, which should be an
  110.             exact alignment on any machine we are likely to
  111.             encounter */
  112.    };
  113.